package java15;

public class StudentsBizs {
	String[] names = new String[30];

	public void addname(String name) {
		for (int i = 0; i < names.length; i++) {
			if (names[i] == null) {
				names[i] = name;
				break;
			}
		}
	}

	public void showname() {
		for (int i = 0; i < names.length; i++) {
			if (names[i] != null) {
				System.out.print(names[i] + "\t");
			}
		}
		System.out.println();
	}

	public boolean editName(String oldname, String newname) {
		boolean find = false;
		for (int i = 0; i < names.length; i++) {
			if (names[i].equals(oldname)) {
				names[i] = newname;
				find = true;
				break;
			}

		}
		return find;
	}

	public boolean searchname(int start, int end, String name) {
		boolean find = false;
		for (int i = start - 1; i < end; i++) {
			if (names[i].equals(name)) {
				find = true;
				break;
			}
		}
		return find;
	}

	public double calavg(int[] scores) {
		int sum = 0;
		double avg = 0.0;
		for (int i = 0; i < scores.length; i++) {
			sum += scores[i];

		}
		avg = (double) sum / scores.length;
		return avg;
	}

	public int calMax(int[] scores) {
		int max = scores[0];
		for (int i = 0; i < scores.length; i++) {
			if (max < scores[i])
				max = scores[i];

		}

		return max;

	}

}
